package com.heima.media.controller;

import com.heima.common.dto.ResponseResult;
import com.heima.media.dto.ChannelDto;
import com.heima.media.entity.WmChannel;
import com.heima.media.service.IWmChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/v1/channel")
public class WmChannelController {

    @Autowired
    IWmChannelService wmChannelService;

    @PostMapping("list")
    public ResponseResult listByName(@RequestBody ChannelDto dto){
        return wmChannelService.listByName(dto);
    }

    @PostMapping
    public ResponseResult saveChannel(@RequestBody WmChannel channel){
        return wmChannelService.saveChannel(channel);
    }

    @GetMapping("/channels")
    public ResponseResult channels() {
        List<WmChannel> list = wmChannelService.list();
        return ResponseResult.okResult(list);
    }


}
